package com.ruoyi.common.cas;//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//


import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.redis.service.RedisService;
import org.jasig.cas.client.ext.AbstractCASClient;
import org.jasig.cas.client.validation.Assertion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.concurrent.TimeUnit;

public class DefaultCASLoginCallback extends AbstractCASClient {
    private static final Logger log = LoggerFactory.getLogger(DefaultCASLoginCallback.class);

    public DefaultCASLoginCallback() {
    }

    @Override
    public boolean onLogin(HttpServletRequest req, HttpServletResponse resp, Assertion assertion) {
        String userId = assertion.getPrincipal().getName();
        RedisService redisService = SpringUtils.getBean(RedisService.class);
        redisService.setCacheObject(CacheConstants.CAS_EMPLOYEE_NO, userId, Constants.TOKEN_EXPIRE * 60, TimeUnit.SECONDS);
        req.getSession().setAttribute("employeeNo", userId);
        return true;
    }
}
